#include "graphic_particle_table.h"

// .. REFERENCES

#include "primitives.h"

// -- PUBLIC

// .. CONSTRUCTORS

GRAPHIC_PARTICLE_TABLE::GRAPHIC_PARTICLE_TABLE() :
    OBJECT(),
    ParticleTable(),
    ParticleCount( 0 )
{
}

// .. OPERATIONS

VOID GRAPHIC_PARTICLE_TABLE::Initialize(
    const COUNT particle_count
    )
{
    COUNT
        table_count;
    INDEX
        table_index;
    FIXED_PARTICLE_TABLE
        new_table;

    memset( &new_table, 0, sizeof( FIXED_PARTICLE_TABLE ) );

    table_count = (INT)( particle_count / LOCAL_FixedParticleCount );

    if( particle_count % LOCAL_FixedParticleCount )
    {
        table_count++;
    }

    for_each_index( table_index, table_count )
    {
        ParticleTable.Add( new_table );
    }

    
    ParticleCount = particle_count;
}

// ~~

VOID GRAPHIC_PARTICLE_TABLE::Reset()
{
    INDEX
        table_index;

    for_each_table_index( table_index, ParticleTable )
    {
        memset( &ParticleTable[ table_index ], 0, sizeof( FIXED_PARTICLE_TABLE ) );
    }
}
